package com.example.config;

import com.example.entity.FreeShop;
import com.example.service.FreeShopService;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: tobed
 * @date: 2022/11/22
 * @time: 11:31
 */
@Component
public class CreateOrderConsumer {

    @Autowired
    FreeShopService freeShopService;

    @RabbitListener(queues = UploadBean.CREATE_SHOP_QUEUE_NAME)
    public void CreateConsumer(Message message){
        String shopId = new String(message.getBody());
        String userId = message.getMessageProperties().getMessageId();
        FreeShop freeShop = new FreeShop();
        freeShop.setUserId(Integer.valueOf(userId));
        freeShop.setShopId(Integer.valueOf(shopId));
        freeShopService.createOder(freeShop);
    }

}
